//
//  AddressMessageCell.m
//  ForestPack
//
//  Created by 郑洲 on 2018/7/20.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "AddressMessageCell.h"

@interface AddressMessageCell ()

@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *addressLabel;
@property (nonatomic, strong) UILabel *phoneLabel;

@end

@implementation AddressMessageCell

+ (AddressMessageCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"AddressMessageCell";
    AddressMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[AddressMessageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        [cell createSubView];
    }
    
    return cell;
}

-(void)setAddressManagerDataModel:(AddressManagerDataModel *)addressManagerDataModel
{
    _addressManagerDataModel = addressManagerDataModel;
    
    self.nameLabel.text = [NSString stringWithFormat:@"收货人：%@",self.addressManagerDataModel.consignee];
    NSString *provinceStr = [[self.addressManagerDataModel.province stringByAppendingString:self.addressManagerDataModel.city] stringByAppendingString:self.addressManagerDataModel.district];
    NSString *addressStr = self.addressManagerDataModel.place;
    self.addressLabel.text = [provinceStr stringByAppendingString:addressStr];
    self.phoneLabel.text = self.addressManagerDataModel.telephone;
}

-(void)setShopOrderDetailModel:(ShopOrderDetailModel *)shopOrderDetailModel
{
    _shopOrderDetailModel = shopOrderDetailModel;
    
    self.nameLabel.text = [NSString stringWithFormat:@"收货人：%@",self.shopOrderDetailModel.consignee];
    NSString *provinceStr = [[self.shopOrderDetailModel.province stringByAppendingString:self.shopOrderDetailModel.city] stringByAppendingString:self.shopOrderDetailModel.district];
    NSString *addressStr = self.shopOrderDetailModel.address;
    self.addressLabel.text = [provinceStr stringByAppendingString:addressStr];
    self.phoneLabel.text = self.shopOrderDetailModel.mobile;
    
}

- (void)createSubView {
    UIImageView *icon = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(22), ScreenX375(22), ScreenX375(22))];
    icon.image = ImageWithName(@"收货地址黑");
    [self addSubview:icon];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(45), ScreenX375(15), ScreenX375(150), ScreenX375(16))];
//    self.nameLabel.text = @"收货人：赵亮";
    self.nameLabel.textColor = FONTCOLOR_BLACK;
    self.nameLabel.font = Kfont(14);
    [self addSubview:self.nameLabel];
    
    self.addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(45), ScreenX375(35), ScreenX375(300), ScreenX375(16))];
//    self.addressLabel.text = @"收货人赵亮收货人赵亮收货人赵亮收货人赵亮收货人赵亮收货人赵亮";
    self.addressLabel.textColor = FONTCOLOR_LIGHTGRAY;
    self.addressLabel.font = Kfont(12);
    [self addSubview:self.addressLabel];
    
    self.phoneLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(139), ScreenX375(15), ScreenX375(100), ScreenX375(16))];
//    self.phoneLabel.text = @"15757166497";
    self.phoneLabel.textColor = FONTCOLOR_BLACK;
    self.phoneLabel.font = Kfont(14);
    [self addSubview:self.phoneLabel];
}

@end
